import time
from concurrent.futures import  Future
from concurrent.futures import  ThreadPoolExecutor
from concurrent.futures import  ProcessPoolExecutor

# concurrent.futures , 是进稆池或线程池也实现异步操作，用到的
def func(value):
    print("begin:{}".format(value))
    time.sleep(3)
    print("end:{}".format(value))
    return "fut:{}".format(value)


pool = ThreadPoolExecutor(max_workers=5)

for i in range(100):
    fut = pool.submit(func, i)
    print(fut.result())
pool.shutdown(True)